# Maintainer: Diego Sogari <diego.sogari@falker.com.br>

_realname=edd-fungo
_depname=edd-test_o_matic
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=0.2.4
depver=0.4.3
pkgrel=1
pkgdesc="C++ library for storing and re-throwing exceptions (mingw-w64)"
arch=('any')
url="https://bitbucket.org/edd/fungo/wiki/Home"
license=('Boost Software License')
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc" "${MINGW_PACKAGE_PREFIX}-cmake")
commit=4055ead96f4c
depcommit=33d4c79fd263
source=("${_realname}-${pkgver}.tar.gz::https://bitbucket.org/edd/fungo/get/${pkgver}.tar.gz"
        "${_depname}-${depver}.tar.gz::https://bitbucket.org/edd/test_o_matic/get/${depver}.tar.gz"
        "${_realname}-${pkgver}-complement.zip")
sha256sums=('cdc3c4340b8a70142fd6f04a4024bb945755bbf348fabdd39565554159e647fe'
            '1e843b8ca8e3875161070b93be7b068c684c140d41c22bd1e3e3086c7d36322b'
            'ad00582d87166d9c90c1f547aacfa367a9d0c8dd89195a9f0e6bba78e70f70bf')

prepare() {
  cd "${srcdir}/${_realname}-${commit}"
  cp -rf ../${_depname}-${depcommit}/* tests/test_o_matic
}

build() {
  rm -rf "${srcdir}/build-${MINGW_CHOST}"
  mkdir "${srcdir}/build-${MINGW_CHOST}"
  cd "${srcdir}/build-${MINGW_CHOST}"

  MSYS2_ARG_CONV_EXCL="-DCMAKE_INSTALL_PREFIX=" \
  ${MINGW_PREFIX}/bin/cmake.exe \
    -G"MSYS Makefiles" \
    -DCMAKE_INSTALL_PREFIX=${MINGW_PREFIX} \
    "../${_realname}-${commit}"

  make
}

check() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  make test
}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  make DESTDIR="${pkgdir}" install
}
